// class to blink msg when mouse move paging mode is on
class cmouseMovePaging {
  cmouseMovePaging(int x, int y, PFont font, color fntColor) {
    this.x = x;
    this.y = y;

    layer = createGraphics(260, 30);
    layer.beginDraw();
    layer.fill(fntColor);
    layer.textFont(font);
    layer.textSize(25);
    layer.endDraw();
  }

  // ======= //
  void show() {
    image(layer, x, y);
  }

  // ======= //
  void toggle() {
    on = !on;

    if (on && noThread) {
      noThread = false;
      thread("threadMouseMovePaging");
    }
  }

  // ======= //
  boolean isOn() {
    return on;
  }

  // ======= //
  void blink() { // called by thread "threadMouseMovePaging"
    while (true) {
      layer.beginDraw();
      layer.text("mouse move paging on", 0, 20);
      layer.endDraw();
      delay(600);

      layer.beginDraw();
      layer.clear();
      layer.endDraw();
      delay(400);

      if (!on) {
        break; // no need blink anymore
      }
    }
    noThread = true;
  }

  // ====== member vars ====== //
  private int x, y;
  private boolean on = false, noThread = true;
  private PGraphics layer;
};

// ====== concrete object ====== //
cmouseMovePaging mouseMovePaging;

// ====== thread to blink msg when mouse move paging enable ====== //
void threadMouseMovePaging() {
  mouseMovePaging.blink();
}
